﻿@using SH = EMoney.IStock.Client.Framework.StringHelper;
@using EMoney.IStock.Client.Models.QQ;
@using EMoney.IStock.Client.Framework;
@{
    Layout = null;
    EmRss emrss = (EmRss)ViewBag.EmRss;
    string[] qq = null;
    if (emrss != null)
    {
        qq = emrss.data;
    }
    string ranktype = ViewBag.RankType;
    string sortName = "default";
    string sortFlag = "default";
    string upordown_rank_key = "", upordown_total_earning = "", upordown_total_asset = "", upordown_position = "", upordown_day_earning = "", upordown_week_earning = "";
    string spanclass_rank_key = "", spanclass_total_earning = "", spanclass_total_asset = "", spanclass_position = "", spanclass_day_earning = "", spanclass_week_earning = "";
    if (ViewBag.SortName != null)
    {
        sortName = ViewBag.SortName;
    }
    if (ViewBag.sortFlag != null)
    {
        sortFlag = ViewBag.sortFlag;
    }

    switch (sortName)
    {
        case "rank_key":
            if (sortFlag == "")
            {
                upordown_rank_key = "↑";
                spanclass_rank_key = "green";
            }
            else
            {
                upordown_rank_key = "↓";
                spanclass_rank_key = "red";
            }
            break;
        case "total_earning":
            if (sortFlag == "")
            {
                upordown_total_earning = "↑";
                spanclass_total_earning = "green";
            }
            else
            {
                upordown_total_earning = "↓";
                spanclass_total_earning = "red";
            }
            break;
        case "total_asset":
            if (sortFlag == "")
            {
                upordown_total_asset = "↑";
                spanclass_total_asset = "green";
            }
            else
            {
                upordown_total_asset = "↓";
                spanclass_total_asset = "red";
            }
            break;
        case "position":
            if (sortFlag == "")
            {
                upordown_position = "↑";
                spanclass_position = "green";
            }
            else
            {
                upordown_position = "↓";
                spanclass_position = "red";
            }
            break;
        case "day_earning":
            if (sortFlag == "")
            {
                upordown_day_earning = "↑";
                spanclass_day_earning = "green";
            }
            else
            {
                upordown_day_earning = "↓";
                spanclass_day_earning = "red";
            }
            break;
        case "week_earning":
            if (sortFlag == "")
            {
                upordown_week_earning = "↑";
                spanclass_week_earning = "green";
            }
            else
            {
                upordown_week_earning = "↓";
                spanclass_week_earning = "red";
            }
            break;
        default:
            break;
    }
}

@{
    if (ranktype == "daping")
    {
    <div class="rank_top">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="11%" align="center" valign="middle" onclick="Sort('rank_key')">
                    <span class="@(spanclass_rank_key)">排名<span>@(upordown_rank_key)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle">高手名称</td>
                <td width="13%" align="center" valign="middle" onclick="Sort('total_earning')">                    
                   <span class="@(spanclass_total_earning)">总收益率%<span>@(upordown_total_earning)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle" onclick="Sort('total_asset')">
                    <span class="@(spanclass_total_asset)">总资产<span>@(upordown_total_asset)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle" onclick="Sort('position')">
                    <span class="@(spanclass_position)">仓位%<span>@(upordown_position)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle" onclick="Sort('day_earning')">
                    <span class="@(spanclass_day_earning)">日收益率%<span>@(upordown_day_earning)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle" onclick="Sort('week_earning')">
                    <span class="@(spanclass_week_earning)">周收益率%<span>@(upordown_week_earning)</span></span>  
                </td>
                <td width="11%" align="center" valign="middle">操作</td>
            </tr>
        </table>
    </div>
    <div class="rank_list">
        <div id="scrollBox1" class="scrollBox" scrollflag style="height: 455px;">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                @{
        List<Rank> rank_lst = (List<Rank>)ViewBag.RankDayLst;
        if(rank_lst != null && rank_lst.Count > 0)
        {
        foreach (Rank rank in rank_lst)
        {
                    <tr onclick="ShowGSJM('@(rank.user_qq)');">
                        <td width="11%" align="center" valign="middle">@(rank.rank_day_key)</td>
                        <td width="13%" align="center" valign="middle" title="@(rank.nickname)">@(StringHelper.StringSubstrLen(rank.nickname,10))</td>
                        <td width="13%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.total_earning))">@(StringHelper.FormatDecimal(rank.total_earning))</span></td>
                        <td width="13%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.total_asset))">@(rank.total_asset)</span></td>
                        <td width="13%" align="center" valign="middle">@(rank.position)</td>
                        <td width="13%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.day_earning))">@(StringHelper.FormatDecimal(rank.day_earning))</span></td>
                        <td width="13%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.week_earning))">@(StringHelper.FormatDecimal(rank.week_earning))</span></td>
                        @{
                            if(qq != null)
                            {
                                string emrsstype = "dy";
                                foreach (string item in qq)
                                {
                                    if (item == rank.user_qq)
                                    {
                                        emrsstype = "qx";
                                    }
                                }
                                if (emrsstype == "qx")
                                { 
                                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="DelEmRss_@(rank.user_qq)" onclick="DelMyEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn2">取消</a></td>
                                }
                                else
                                {
                                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="AddEmRss_@(rank.user_qq)" onclick="AddEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn1">订阅</a></td>
                                }
                            }else
                            {
                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="AddEmRss_@(rank.user_qq)" onclick="AddEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn1">订阅</a></td>
                            }
                        }
                    </tr>     
        }
        }else
        {
            <tr><td colspan="8" style="text-align:center;">--无记录--</td></tr>
        }
                }
            </table>
        </div>
    </div>
    }
    else
    {
    <div class="rank_top">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="11%" align="center" valign="middle" onclick="Sort('rank_key')">
                    <span class="@(spanclass_rank_key)">排名<span>@(upordown_rank_key)</span></span>  
                </td>
                <td width="21%" align="center" valign="middle">高手名称</td>
                <td width="17%" align="center" valign="middle" onclick="Sort('total_earning')">
                    <span class="@(spanclass_total_earning)">总收益率%<span>@(upordown_total_earning)</span></span>  
                </td>
                <td width="24%" align="center" valign="middle" onclick="Sort('total_asset')">
                    <span class="@(spanclass_total_asset)">总资产<span>@(upordown_total_asset)</span></span>  
                </td>
                <td width="14%" align="center" valign="middle" onclick="Sort('position')">
                    <span class="@(spanclass_position)">仓位%<span>@(upordown_position)</span></span>  
                </td>
                <td width="13%" align="center" valign="middle">操作</td>
            </tr>
        </table>
    </div>
    <div class="rank_list">
        <div id="scrollBox1" class="scrollBox" scrollflag style="height: 455px;">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                @{
        List<Rank> rank_lst = (List<Rank>)ViewBag.RankDayLst;
        if(rank_lst != null && rank_lst.Count > 0)
        {
        foreach (Rank rank in rank_lst)
        {    
                    <tr onclick="ShowGSJM('@(rank.user_qq)');">
                        <td width="11%" align="center" valign="middle">@(rank.rank_day_key)</td>
                        <td width="21%" align="center" valign="middle" title="@(rank.nickname)">@(StringHelper.StringSubstrLen(rank.nickname,10))</td>
                        <td width="17%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.total_earning))">@(StringHelper.FormatDecimal(rank.total_earning))</span></td>
                        <td width="24%" align="center" valign="middle"><span class="@(StringHelper.FormatQQColor(rank.total_asset))">@(rank.total_asset)</span></td>
                        <td width="14%" align="center" valign="middle">@(rank.position)</td>
                        @{
                            if(qq !=null)
                            {
                                string emrsstype = "dy";
                                foreach (string item in qq)
                                {
                                    if (item == rank.user_qq)
                                    {
                                        emrsstype = "qx";
                                    }
                                }
                                if (emrsstype == "qx")
                                { 
                                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="DelEmRss_@(rank.user_qq)" onclick="DelMyEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn2">取消</a></td>
                                }
                                else
                                {
                                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="AddEmRss_@(rank.user_qq)" onclick="AddEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn1">订阅</a></td>
                                }
                            }else
                            {
                                <td width="11%" align="center" valign="middle"><a hidefocus="true" id="AddEmRss_@(rank.user_qq)" onclick="AddEmRss('@(rank.user_qq)',event)" href="javascript:;" class="btn1">订阅</a></td>
                            }
                        }
                    </tr>   
        }
        }else
        {
            <tr><td colspan="6" style="text-align:center;">--无记录--</td></tr>
        }
                }
            </table>
        </div>
    </div>
    }
}
<script>
    $(function () {
        //初始化滚动条
        $(".scrollBox").jscroll({ W: "7px", IW: "7px", CurrT: 0, Bar: { Pos: "up" }, Btn: { btn: false }, Fn: function () { } }).hover(function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.addClass("mon").stop(true, true, false).show();
            }
        }, function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.removeClass("mon");
                if (scrlbr.hasClass("vxdrag")) { } else {
                    //scrlbr.fadeOut("slow");
                }
            }
        });
        var hh = document.documentElement.clientHeight;
        var xx = hh - 16;
        var data_box = hh - 176;
        $("#scrollBox1").css("height", data_box);
        ReSetScroll();
    })
    
</script>